﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using TPOJ.IDAL;
using System.Reflection;

namespace TPOJ.DALFactory
{
    public static class DataAccess
    {
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];

        public static IProblemDAO CreateProblemDAO()
        {
            string className = path + ".ProblemDAO";
            return (IProblemDAO)Assembly.Load(path).CreateInstance(className);
        }

        public static ISolutionDAO CreateSolutionDAO()
        {
            string className = path + ".SolutionDAO";
            return (ISolutionDAO)Assembly.Load(path).CreateInstance(className);
        }

        public static IAccountDAO CreateAccountDAO()
        {
            string className = path + ".AccountDAO";
            return (IAccountDAO)Assembly.Load(path).CreateInstance(className);
        }

        public static IContestDAO CreateContestDAO()
        {
            string className = path + ".ContestDAO";
            return (IContestDAO)Assembly.Load(path).CreateInstance(className);
        }

        public static IForumDAO CreateForumDAO()
        {
            string className = path + ".ForumDAO";
            return (IForumDAO)Assembly.Load(path).CreateInstance(className);
        }
    }
}
